/***************************************************************************
 *   Copyright (C) 2009 by Bernhard Neuhofer   *
 *   mail@bneu.at   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include "taxiStandSqtwAdapter.h"
#include "sqtwAdapter.h"
#include "modelentity.h"
#include "memento.h"
#include "taxiStand.h"
#include <typeinfo>
#include "taxtArrival.h"

Memento* TaxiStandSqtwAdapter::createMemento(ModelEntity* modelentity)
{
	return new TaxiStandSqtwMemento(dynamic_cast<TaxiStand*>(modelentity)->getNrCustomers());
}

void TaxiStandSqtwAdapter::setMemento(ModelEntity* modelentity,Memento* memento)
{
	dynamic_cast<TaxiStand*>(modelentity)->setNrCustomers(dynamic_cast<TaxiStandSqtwMemento*>(memento)->getNrCustomers());
}

unsigned int TaxiStandSqtwAdapter::intoWhichQueue(Message* message)
{
  if (typeid(message)==typeid(TaxiArrival*))
	return 1; else return 0;
}



unsigned int TaxiStandSqtwAdapter::outOfWhichQueue(ModelEntity* modelentity)
{
  if(dynamic_cast<TaxiStand*>(modelentity)->getNrCustomers()==0)
	return 0; //customer queue
	else 
	return 1; //taxi queue
}


TaxiStandSqtwAdapter::TaxiStandSqtwMemento::TaxiStandSqtwMemento(unsigned int nrCustomers):_nrCustomers(nrCustomers){};

unsigned int TaxiStandSqtwAdapter::TaxiStandSqtwMemento::getNrCustomers()
{
return _nrCustomers;
}

void TaxiStandSqtwAdapter::TaxiStandSqtwMemento::setNrCustomers(unsigned int nrCustomers)
{
 _nrCustomers=nrCustomers;
}